/*
============================================================================
 Name        : fFile.h
 Author      :
 Version     :
 Copyright   : Your copyright notice
 Description : CfFile declaration
============================================================================
*/

#ifndef __f_FILE_H__
#define __f_FILE_H__

#include "ApplicationScheme.h"
#include <e32std.h>
#include <e32base.h>
#include <f32file.h>
#include "TextConvert.h"


class fFile
{
	public:
		enum TFileErrorCode
		{
			f_FILE_MEMORYFAILED		= -1,
			f_FILE_OPENFAILED		= -2,
			f_FILE_REPLACEFAILED		= -3,
			f_FILE_READFAILED		= -4,
			f_FILE_WRITEFAILED		= -5,
			f_FILE_GETSIZEFAILED		= -6,
			f_FILE_SETSIZEFAILED		= -7,
			f_FILE_DELETEFAILED		= -8,
			f_FILE_SEEKFAILED		= -9,
		};
	public:
		static int Read( const TDesC& aPath, int aLength, TDes8& aBuffer, int nShareMode = EFileShareAny | EFileRead );
		static int Read( const TDesC& aPath, int aLength, TDes& aBuffer, int nShareMode = EFileShareAny | EFileRead );
        static int Read( const char* szPath, TInt nPosition, int nLength, unsigned char* lpBuffer,  int nShareMode = EFileShareAny | EFileRead );
        static int Read( const char* szPath, int nLength, unsigned char* lpBuffer,  int nShareMode = EFileShareAny | EFileRead );
        static HBufC8* Read( const TDesC& aPath, int nShareMode = EFileShareAny | EFileRead );
        static HBufC8* Read( const TDesC& aPath, TInt aPosition, int aLength, int nShareMode = EFileShareAny | EFileRead );
        static int ReadInt( const TDesC& aPath, TInt aPosition, int nShareMode = EFileShareAny | EFileRead );

        static HBufC* ReadGBFile(const TDesC& aPath, int nShareMode = EFileShareAny | EFileRead);
		static HBufC* ReadTextToUnicode( const TDesC &aPath, fTextConverter::TCharSet aCharSet, int nShareMode = EFileShareAny | EFileRead );
		static int Write( const TDesC& aPath, int aLength, const TDesC8& aBuffer, int nShareMode = EFileShareAny | EFileWrite );
        static int Write( const char* szPath, int nLength, unsigned char* lpBuffer, int nShareMode = EFileShareAny | EFileWrite );
        static int Write( const char* szPath, unsigned char* szString, int nShareMode = EFileShareAny | EFileWrite);

        static int Append( const TDesC& aPath, int aLength, const TDesC8& aBuffer, int nShareMode = EFileShareAny | EFileWrite );
		static int Append( const TDesC& aPath, const TDesC8& aString, int nShareMode = EFileShareAny | EFileWrite );
        static int Append( const char* szPath, int nLength, unsigned char* lpBuffer, int nShareMode = EFileShareAny | EFileWrite );
        static int Append( const char* szPath, unsigned char* szString, int nShareMode = EFileShareAny | EFileWrite);

        static int GetLength( const TDesC& aPath, int nShareMode = EFileShareAny | EFileWrite );
        static int GetLength( const char* szPath, int nShareMode = EFileShareAny | EFileWrite );

        static int DeleteFile( const TDesC& aPath );
        static int DeleteFile( const char* szPath );

        static TBool IsDriveEExist();
};
#endif // __f_FILE_H__
